1. Field of the Invention
The present invention relates to an access control method, access control apparatus, and computer-readable memory storing an access control program and, more particularly, to an access control method, access control apparatus, and computer-readable memory storing an access control program that are suitable for using a flash ROM as a data storage area.
2. Description of the Related Art
In general, a file system uses a secondary storage device such as a floppy disk device or hard disk device as a data storage area. Such secondary storage device can be generally random-accessed in units of 512-or 1,024-byte blocks.
This secondary storage device is disadvantageous because of a low access speed and an access only in units of blocks. For this reason, the file system using this secondary storage device prepares a buffer cache on a memory such as a RAM to suppress an actual access frequency to the secondary storage device so as to improve performance, and to allow a file system user (user program) to access the secondary storage device in not block units but arbitrary units.
In recent years, the secondary storage device is being replaced with a flash ROM for the data storage area of the file system. In this case, an access with the same interface as the secondary storage device (floppy disk device or hard disk device) is enabled by preparing a special software driver (to be referred to as a flash disk driver) which enables a random read/write in units of blocks. This makes it possible to use a file system using the flash disk driver in the same form as the file system using the conventional floppy disk device or hard disk device as a data storage area.
However, if the file system using the flash ROM as a data storage area is realized by the file system using the conventional buffer cache, it is difficult to take full advantage of the flash ROM, and some problems arise. These problems will be described.
The flash ROM generally requires a special command sequence for a write, but can be directly accessed for a read similarly to a general memory. The flash ROM is lower in read access speed than the RAM but much higher than the disk device.
Despite of these characteristics, the conventional file system first reads out data to the buffer cache in units of blocks, and then copies the data to the memory area of a user even when a file system user (user program) performs only read processing. This poses the following problems:
(1) In a read, data can be directly copied from the flash ROM to the memory area of the user, but is wastefully copied to the buffer cache. Hence, the read processing time becomes undesirably long.
(2) The buffer cache is unpreferably assigned to a block associated with only read processing. That is, assignment of a buffer cache unnecessary for a read is done to decrease the memory utilization efficiency. This reduces another memory area such as a cache block area (i.e., a memory area used by a cache block assigned in a buffer cache) necessary for write processing.
The present invention has been made to solve the above drawbacks, and has as its object to make it possible to directly transfer data from a storage medium to the memory area of a user program in a data read in a file system which accesses a storage medium capable of being directly accessed by designating memory address in units of blocks.
To achieve the above object, an access control method according to one aspect of the present invention comprises the following steps.
That is, an access control method for accessing a storage medium capable of being directly accessed by designating memory address and a buffer for temporarily holding contents of the storage medium, comprises the generation step of generating block access information for accessing the storage medium in units of blocks on the basis of an access request designated by a user program, the calculation step of calculating an access address to the storage medium on the basis of an access destination block designated by the block access information, the copying step of, when the access request is a data read request, accessing, on the basis of the data read request, the storage medium using the block access information generated in the generation step and the access address calculated in the calculation step, and copying obtained data to a memory area managed by the user program, and the write step of, when the access request is a data write request, writing data on the basis of the data write request via the buffer using the block access information generated in the generation step and the access address calculated in the calculation step.
To achieve the above object, an access control apparatus according to another aspect of the present invention comprises the following arrangement.
That is, an access control apparatus for accessing a storage medium capable of being directly accessed by designating memory address and a buffer for temporarily holding contents of the storage medium, comprises generation means for generating block access information for accessing the storage medium in units of blocks on the basis of an access request designated by a user program, calculation means for calculating an access address to the storage medium on the basis of an access destination block designated by the block access information, copying means for, when the access request is a data read request, accessing, on the basis of the data read request, the storage medium using the block access information generated by the generation means and the access address calculated by the calculation means, and copying obtained data to a memory area managed by the user program, and write means for, when the access request is a data write request, writing data on the basis of the data write request via the buffer using the block access information generated by the generation means and the access address calculated by the calculation means.
Other features and advantages of the present invention will be apparent from the following description taken in conjunction with the accompanying drawings, in which like reference characters designate the same or similar parts throughout the figures thereof.